import math
class Solution(object):
    def ipToCIDR(self, ip, n):
        """
        :type ip: str
        :type n: int
        :rtype: List[str]
        """
        ip_list = ip.split('.')
        num = 0
        def decode(num):
            s = ''
            for i in range(4):
                now_num = 0
                now_num += ((num >> (8 * (4 - i - 1))) & 255)
                s += str(now_num)
                if i != 3:
                    s += '.'
            return s
        for i in range(4):
            num += (int(ip_list[i]) << (8 * (4 - i - 1)))
        index = 0
        out = []
        while ((num >> index) & 1) == 1:
            index += 1
        if index > 0:
            out.append(decode(num) + '/32')
            n = n - 1
            for _ in range(index):
                num = num & (num - 1)
            num += 2 ** index
        while index < 32:
            if ((num >> index) & 1) == 1:
                if n >= 2 ** index:
                    out.append(decode(num) + '/' + str(32 - index))
                    n -= 2 ** index
                    num = num & (num - 1)
                    num += 2 ** (index + 1)
                else:
                    while n > 0:
                        k = int(math.log2(n))
                        out.append(decode(num) + '/' + str(32 - k))
                        n = n - 2 ** k
                        num += 2 ** k
                    break
            index += 1
        while n > 0:
            k = int(math.log2(n))
            out.append(decode(num) + '/' + str(32 - k))
            n = n - 2 ** k
            num += 2 ** k

        return out




data = Solution()
# ip = "117.145.102.62"
# n = 8
# print(data.ipToCIDR(ip, n))
ip = "0.0.0.0"
n = 8
print(data.ipToCIDR(ip, n))
